package com.leizhou.springboot.service;

import com.leizhou.springboot.mapper.UserMapper;
import com.leizhou.springboot.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * @author LT
 * @version 1.0.0
 * @ClassName UserService.java
 * @Description TODO
 * @createTime 2020年04月16日 22:13:00
 */
@Service
@Transactional
public class UserService {

    @Autowired(required = false)
    private UserMapper userMapper;

    /**
     * 查询全部用户
     *
     * @return
     */
    // public List<User> findAll() {
    //     return userMapper.findAll();
    // }
    public List<User> findAll() {
        return userMapper.selectAll();
    }

    public void save(User user) {
        user.setCreated(new Date());
        user.setUpdated(user.getCreated());
        userMapper.insertSelective(user);
    }
}
